package com.example.loopyserver.controller;


import com.example.loopyserver.common.CommonController;
import com.example.loopyserver.dto.LocationDTO;
import com.example.loopyserver.exception.CommonException;
import com.example.loopyserver.server.LocationService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@CommonController
@RequiredArgsConstructor
@RequestMapping("/location")
public class LocationController {
    private final LocationService locationService;

    @GetMapping("/{key}")
    public LocationDTO getLocation(@PathVariable String key) throws CommonException {
        return locationService.getLocation(key);
    }

    @PostMapping("/{key}")
    public void getLocation(@PathVariable String key, @RequestBody @Valid LocationDTO location) {
        locationService.setLocation(key, location);
    }
}
